home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Readers / Gui4Cli / Tools / FileReq.gc < prev    next >
Text File  |  1997-12-02  |  6KB  |  257 lines

  1. G4C
  2.  
  3. ; FILEREQ.GC
  4. ; A multiselect File Requester with Favourites etc..
  5.  
  6. ; GuiLoad guis:tools/filereq.gc  GuiName Routine Path FavFile  -or
  7. ; GuiOpen filereq.gc  GuiName Routine Path FavFile
  8.  
  9. ; GuiName  - Name of your gui
  10. ; Routine  - Routine in your gui that will be called
  11. ; Path     - (optional) path to open at - if you want..
  12. ; FavFile  - (optional) name of the Favourites file
  13.  
  14. ; ====================================================================
  15.  
  16. ;               Globals
  17.  
  18. ; ====================================================================
  19.  
  20. WINBIG 185 16 291 213 'Choose file(s) :'
  21. WinType 11110001
  22. varpath ''
  23.  
  24. BOX 0 0 0 0 in icondrop
  25.  
  26.  
  27. ; ====================================================================
  28.  
  29. ;               System events
  30.  
  31. ; ====================================================================
  32.  
  33. xONLOAD  gui routine path favfile 
  34. if  $gui > ''        ; dont pass them if you just want to load it.
  35. and $routine > ''
  36.     guiopen filereq.gc $gui $routine $path $favfile
  37. endif
  38.  
  39. xONRELOAD  gui routine path favfile 
  40. guiopen filereq.gc $gui $routine $path $favfile
  41.  
  42.  
  43. XONOPEN  gui routine path favfile 
  44. setgad filereq.gc 52/53 off
  45. if $path > ''
  46.    lvuse filereq.gc 1
  47.    LVDir '#$path'
  48.    update filereq.gc 2 $$lv.dir      
  49. endif
  50. if $favfile = ""
  51.    favfile = guis:tools/fav/default
  52. endif
  53.  
  54.  
  55. xOnRMB
  56. if $mode = FAV
  57.    setgad filereq.gc 52/53 off
  58.    setgad filereq.gc 2/16 on
  59.    setgad filereq.gc 50/51 on
  60.    lvuse filereq.gc 1
  61.    lvmode DIR
  62.    lvdir #$$lv.dir
  63. else
  64.    status
  65. endif
  66.  
  67.  
  68. ; ====================================================================
  69.  
  70. ;               The Listview
  71.  
  72. ; ====================================================================
  73.  
  74. XLISTVIEW 9 5 213 190 "" filename "" 10 DIR
  75. GADID 1
  76. GADFONT #mono 8 000
  77. if $mode = FAV
  78.    setgad filereq.gc 52/53 off
  79.    setgad filereq.gc 2/16 on
  80.    setgad filereq.gc 50/51 on
  81.    mode = ''
  82.    lvmode DIR
  83.    lvdir #$filename
  84. else
  85.    guiclose filereq.gc
  86.    gosub $gui $routine $filereq.gc/filename  ; Give FULL variable path!
  87. endif
  88.  
  89.  
  90. ; directory hook
  91. xlvdirhook 1
  92. update filereq.gc 2 $filename       
  93.  
  94.  
  95. ; single click hook
  96. xlvhook 1
  97. update filereq.gc 2 $filename
  98.  
  99.  
  100. XTEXTIN 9 194 273 14 "" txtfile "" 100
  101. GADID 2
  102. gadhelp 'Shows file chosen - Change the name & hit enter, to Rename it'
  103. ifexists file $txtfile
  104.    guiclose filereq.gc
  105.    gosub $gui $routine $filereq.gc/filename
  106. else
  107.    ezreq 'Rename $filename\nto $txtfile ?' Rename|CANCEL choice
  108.    if $choice = 1
  109.       rename $filename $txtfile
  110.       lvuse filereq.gc 1
  111.       lvdir refresh
  112.    endif
  113. endif
  114.  
  115.  
  116. ; ====================================================================
  117.  
  118. ;               Listview control buttons
  119.  
  120. ; ====================================================================
  121.  
  122. XBUTTON 224 5 58 14 "Parent"
  123. gadid 10
  124. gadhelp 'CD to Parent of current dir'
  125. lvuse filereq.gc 1
  126. LVDir parent
  127. update filereq.gc 2 $$lv.dir      
  128.  
  129.  
  130. XBUTTON 224 19 58 14 "Root"
  131. gadid 11
  132. gadhelp 'CD to Root of current dir'
  133. lvuse filereq.gc 1
  134. LVDir root
  135. update filereq.gc 2 $$lv.dir      
  136.  
  137.  
  138. XBUTTON 224 33 58 14 "Disks"
  139. gadid 12
  140. gadhelp 'Show device list'
  141. lvuse filereq.gc 1
  142. LVDir disks
  143. update filereq.gc 2 $$lv.dir      
  144.  
  145.  
  146. XBUTTON 224 47 58 14 "All"
  147. gadid 13
  148. gadhelp 'Select all items'
  149. lvuse filereq.gc 1
  150. LVDir all
  151. update filereq.gc 2 $$lv.dir      
  152.  
  153.  
  154. XBUTTON 224 61 58 14 "None"
  155. gadid 14
  156. gadhelp 'Unselect all items'
  157. lvuse filereq.gc 1
  158. LVDir none
  159. update filereq.gc 2 $$lv.dir      
  160.  
  161. ; ====================================================================
  162.  
  163. ;               Copy & delete
  164.  
  165. ; ====================================================================
  166.  
  167. XBUTTON 224 92 58 14 "Copy"
  168. gadid 14
  169. gadhelp 'Copy selected files (destination chosen through requester)'
  170. dest = ''
  171. ReqFile -1 -1 300 -40 'Choose destination:' DIR dest ''
  172. if $dest > ' '
  173.    lvuse filereq.gc 1
  174.    lvaction copy $dest
  175. endif
  176.  
  177. XBUTTON 224 78 58 14 "Delete"
  178. gadid 14
  179. gadhelp 'Delete selected files'
  180. lvuse filereq.gc 1
  181. lvaction delete REQ
  182.  
  183.  
  184. ; ====================================================================
  185.  
  186. ;               Favourites control
  187.  
  188. ; ====================================================================
  189.  
  190. XBUTTON 224 110 58 14 "Fav"
  191. gadid 50
  192. gadhelp 'Shows Favourites listing ($favfile\)'
  193. setgad filereq.gc 2/16 off
  194. setgad filereq.gc 50/51 off
  195. setgad filereq.gc 52/53 on
  196. lvuse filereq.gc 1
  197. lvmode MULTI
  198. lvchange $favfile
  199. lvsort asc
  200. mode = FAV
  201.  
  202.  
  203. XBUTTON 224 124 29 14 "+"       ; add to favourites
  204. gadid 51                        ; create file if it doesn't exist
  205. gadhelp 'Add current dir to Favourites'
  206. ifexists file $favfile
  207.    ; ok
  208. else
  209.    .dummy = 'GUIs:'             ; got to have this one :)
  210.    copy env:.dummy $favfile
  211. endif
  212. lvuse filereq.gc 1
  213. append $favfile '\n$$lv.dir'
  214.  
  215.  
  216. XBUTTON 253 124 29 14 "-"     ; delete from favourites
  217. gadid 52
  218. gadhelp 'Deleted selected favourites entries'
  219. lvuse filereq.gc 1
  220. lvmulti first
  221. while $filename > ''
  222.     lvdel -1
  223.     lvmulti first      ; since we deleted the old 1st one
  224. endwhile
  225.  
  226.  
  227. XBUTTON 224 138 58 14 "Save"  ; save favourites
  228. gadid 53
  229. gadhelp 'Save Favourites as $favfile'
  230. lvuse filereq.gc 1
  231. lvsave $favfile
  232.  
  233. ; ====================================================================
  234.  
  235. ;               OK & Cancel
  236.  
  237. ; ====================================================================
  238.  
  239. XBUTTON 224 157 58 19 "OK"
  240. gadid 15
  241. gadhelp 'Selected files will be sent to calling gui'
  242. guiclose filereq.gc
  243. lvuse filereq.gc 1
  244. lvmulti first
  245. while $filename > ''
  246.    gosub $gui $routine $filereq.gc/filename
  247.    lvmulti off
  248.    lvmulti next
  249. endwhile
  250.  
  251. XBUTTON 224 176 58 17 "Cancel"
  252. gadid 16
  253. guiclose filereq.gc
  254.  
  255.  
  256.  
  257.